package com.hmall.api.config;

import com.hmall.common.utils.UserContext;
import feign.Logger;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;

public class DefaultFeignConfig {
    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.BASIC;
    }

    @Bean
    public RequestInterceptor UserInfoRequestInterceptor() {
        return template -> {
            if (UserContext.getUser() != null){
                template.header("user-info", UserContext.getUser().toString());
            }
        };
    }
}
